//
//  MCGameRecordDetailViewController.m
//  TLYL
//
//  Created by miaocai on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCGameRecordDetailViewController.h"
#import "MCPickNumberViewController.h"
#import "MCGameRecordDetailModel.h"
#import "MCCancleLotteryModel.h"
#import "MCGameRecordDetailCollectionViewCell.h"

@interface MCGameRecordDetailViewController ()<UICollectionViewDataSource>

@property (nonatomic,strong) MCGameRecordDetailModel *gameRecordModel;
@property (nonatomic,strong) MCGameRecordDetailModel *data;
@property (nonatomic,strong) UILabel *dingDanDetailLabel;
@property (nonatomic,strong) UILabel *liuShuiDetailLabel;
@property (nonatomic,strong) UILabel *zhuiDetailLabel;
@property (nonatomic,strong) UILabel *lotteryLabel;
@property (nonatomic,strong) UILabel *qihaoDetailLabel;
//玩法名称
@property (nonatomic,strong) UILabel *wanfaDetailLabel;
@property (nonatomic,strong) UILabel *dateDetailLabel;
@property (nonatomic,strong) UILabel *zhuDanDetailLabel;
@property (nonatomic,strong) UILabel *jiangJinDetailLabel;
@property (nonatomic,strong) UILabel *gouMaiDeailLabel;
@property (nonatomic,strong) UILabel *zhongJDetailLabel;
@property (nonatomic,strong) UILabel *touzhuDetailLabel;
@property (nonatomic,strong) UILabel *lotteryBtn;
@property (nonatomic,strong) UIButton *btn;
@property (nonatomic,strong) UILabel *wanfaLabel;
@property (nonatomic,strong) UILabel *dateLabel;
@property (nonatomic,strong) UIView *lineView2;
@property (nonatomic,strong) UILabel *zhuDanLabel;
@property (nonatomic,strong) UILabel *gouMaiLabel;
@property (nonatomic,strong) UILabel *zhongJLabel;
@property (nonatomic,strong) UILabel *jiangJinLabel;
@property (nonatomic,strong) UIButton *touzhuBtnCopy;
@property (nonatomic,strong) UIButton *contnueBtn;
@property (nonatomic,strong) UILabel *touzhuLabel;
@property (nonatomic,strong) UIButton *dingDanBtnCopy;
@property (nonatomic,strong) MCCancleLotteryModel *cancelModel;
//@property (nonatomic,strong) UILabel *kaiJiangDetailLabel;
@property (nonatomic,weak) UIScrollView *baseScrollView;
@property (nonatomic,weak) UILabel *kaiJiangLabel;
@property (nonatomic,weak) UICollectionView *collectionView;
@property (nonatomic,strong) NSMutableArray *collectionViewArray;
@end

@implementation MCGameRecordDetailViewController
- (NSMutableArray *)collectionViewArray{
    if (_collectionViewArray == nil) {
        _collectionViewArray = [NSMutableArray array];
    }
    return _collectionViewArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"订单详情";
    self.view.backgroundColor = [UIColor whiteColor];
    [self addNavRightBtn];
    [self setUpUI];
    [self loadDataAndShow];
}

- (void)addNavRightBtn {
    
    UIButton *btn = [[UIButton alloc] init];
    self.btn = btn;
    [btn setTitle:@"撤单" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
    btn.frame = CGRectMake(0, 0, MC_REALVALUE(44), MC_REALVALUE(44));
    [btn addTarget:self action:@selector(cancleBtnClick:) forControlEvents:UIControlEventTouchDown];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.rightBarButtonItem = rightItem;
}

- (void)setUpUI{
    
    UIScrollView *baseScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:baseScrollView];
    self.baseScrollView = baseScrollView;
    UILabel *dingDanLabel = [[UILabel alloc] init];
    dingDanLabel.text = @"订单号：";
    [baseScrollView addSubview:dingDanLabel];
    dingDanLabel.textColor = RGB(102, 102, 102);
    dingDanLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *dingDanDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:dingDanDetailLabel];
    dingDanDetailLabel.text = @"正在加载";
    dingDanDetailLabel.textColor = RGB(102, 102, 102);
    dingDanDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UIButton *dingDanBtnCopy = [[UIButton alloc] init];
    [dingDanBtnCopy setTitle:@"复制" forState:UIControlStateNormal];
    dingDanBtnCopy.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [baseScrollView addSubview:dingDanBtnCopy];
    [dingDanBtnCopy setTitleColor:MC_SKYBLUE_COLOR forState:UIControlStateNormal];
    dingDanBtnCopy.layer.borderWidth = 1.0f;
    dingDanBtnCopy.layer.borderColor = MC_SKYBLUE_COLOR.CGColor;
    dingDanBtnCopy.layer.cornerRadius = 2;
    [dingDanBtnCopy addTarget:self action:@selector(dingDanBtnCopyClick) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel *liuShuiLabel = [[UILabel alloc] init];
    liuShuiLabel.text = @"流水号：";
    [baseScrollView addSubview:liuShuiLabel];
    
    UILabel *liuShuiDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:liuShuiDetailLabel];
    liuShuiLabel.textColor = RGB(102, 102, 102);
    liuShuiLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    liuShuiDetailLabel.textColor = RGB(102, 102, 102);
    liuShuiDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    UIButton *liuShuiBtnCopy = [[UIButton alloc] init];
    [liuShuiBtnCopy setTitle:@"复制" forState:UIControlStateNormal];
    liuShuiBtnCopy.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [baseScrollView addSubview:liuShuiBtnCopy];
    [liuShuiBtnCopy setTitleColor:MC_SKYBLUE_COLOR forState:UIControlStateNormal];
    liuShuiBtnCopy.layer.borderWidth = 1.0f;
    liuShuiBtnCopy.layer.borderColor = MC_SKYBLUE_COLOR.CGColor;
    liuShuiBtnCopy.layer.cornerRadius = 2;
    [liuShuiBtnCopy addTarget:self action:@selector(liuShuiBtnCopyClick) forControlEvents:UIControlEventTouchUpInside];
    liuShuiDetailLabel.text = @"正在加载";
    
    UILabel *zhuiLabel = [[UILabel alloc] init];
    zhuiLabel.text = @"中奖后停止追号：";
    [baseScrollView addSubview:zhuiLabel];
    
    UILabel *zhuiDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:zhuiDetailLabel];
    zhuiDetailLabel.text = @"";
    UIView *lineView1 = [[UIView alloc] init];
    [baseScrollView addSubview:lineView1];
    lineView1.backgroundColor = RGB(233, 233, 233);
    
    zhuiLabel.textColor = RGB(102, 102, 102);
    zhuiLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    zhuiDetailLabel.textColor = RGB(102, 102, 102);
    zhuiDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    UILabel *lotteryLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:lotteryLabel];
    lotteryLabel.text = @"正在加载";
    UILabel *lotteryBtn = [[UILabel alloc] init];
    lotteryBtn.text = @"正在加载";
    self.lotteryBtn = lotteryBtn;
    lotteryBtn.textColor = MC_SKYBLUE_COLOR;
    lotteryBtn.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    [baseScrollView addSubview:lotteryBtn];
 
    lotteryLabel.textColor = RGB(102, 102, 102);
    lotteryLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];

    
    UILabel *qihaoLabel = [[UILabel alloc] init];
    qihaoLabel.text = @"期号：";
    [baseScrollView addSubview:qihaoLabel];
    
    UILabel *qihaoDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:qihaoDetailLabel];
    qihaoDetailLabel.text = @"正在加载";
    UILabel *kaiJiangLabel = [[UILabel alloc] init];
    self.kaiJiangLabel = kaiJiangLabel;
    qihaoLabel.textColor = RGB(102, 102, 102);
    qihaoLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    qihaoDetailLabel.textColor = RGB(102, 102, 102);
    qihaoDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    kaiJiangLabel.text = @"开奖号码：";
    
 
    

    [baseScrollView addSubview:kaiJiangLabel];
    kaiJiangLabel.textColor = RGB(102, 102, 102);
    kaiJiangLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *wanfaLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:wanfaLabel];
    wanfaLabel.text = @"玩法:";
    UILabel *wanfaDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:wanfaDetailLabel];
    wanfaDetailLabel.text = @"正在加载";
    wanfaLabel.textColor = RGB(102, 102, 102);
    wanfaLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    wanfaDetailLabel.textColor = RGB(102, 102, 102);
    wanfaDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *dateLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:dateLabel];
    dateLabel.text = @"购买时间：";
    UILabel *dateDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:dateDetailLabel];
    dateDetailLabel.text = @"正在加载";
    dateLabel.textColor = RGB(102, 102, 102);
    dateLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UIView *lineView2 = [[UIView alloc] init];
    [baseScrollView addSubview:lineView2];
    lineView2.backgroundColor = RGB(233, 233, 233);
    dateDetailLabel.textColor = RGB(102, 102, 102);
    dateDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    
    
    UILabel *zhuDanLabel = [[UILabel alloc] init];
    zhuDanLabel.text = @"注单详情：";
    [baseScrollView addSubview:zhuDanLabel];
    
    UILabel *zhuDanDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:zhuDanDetailLabel];
    zhuDanLabel.textColor = RGB(102, 102, 102);
    zhuDanLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    zhuDanDetailLabel.textColor = RGB(102, 102, 102);
    zhuDanDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *gouMaiLabel = [[UILabel alloc] init];
    gouMaiLabel.text = @"购买金额：";
    [baseScrollView addSubview:gouMaiLabel];
    
    UILabel *gouMaiDeailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:gouMaiDeailLabel];
    gouMaiDeailLabel.text = @"正在加载";
    
    UILabel *zhongJLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:zhongJLabel];
    zhongJLabel.text = @"中奖注数：";
    gouMaiLabel.textColor = RGB(102, 102, 102);
    gouMaiLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    gouMaiDeailLabel.textColor = RGB(102, 102, 102);
    gouMaiDeailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    zhongJLabel.textColor = RGB(102, 102, 102);
    zhongJLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *zhongJDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:zhongJDetailLabel];
    zhongJDetailLabel.text = @"正在加载";
    zhongJDetailLabel.textColor = RGB(102, 102, 102);
    zhongJDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *jiangJinLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:jiangJinLabel];
    jiangJinLabel.text = @"奖金：";
    jiangJinLabel.textColor = RGB(102, 102, 102);
    jiangJinLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *jiangJinDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:jiangJinDetailLabel];
    jiangJinDetailLabel.text = @"正在加载";
    jiangJinDetailLabel.textColor = RGB(102, 102, 102);
    jiangJinDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UILabel *touzhuLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:touzhuLabel];
    touzhuLabel.text = @"投注号码：";

    UILabel *touzhuDetailLabel = [[UILabel alloc] init];
    [baseScrollView addSubview:touzhuDetailLabel];
    
    touzhuDetailLabel.textColor = RGB(102, 102, 102);
    touzhuDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    touzhuDetailLabel.numberOfLines = 0;
    touzhuLabel.textColor = RGB(102, 102, 102);
    touzhuLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UIButton *touzhuBtnCopy = [[UIButton alloc] init];
    [touzhuBtnCopy setTitle:@"复制" forState:UIControlStateNormal];
    [baseScrollView addSubview:touzhuBtnCopy];
    [touzhuBtnCopy setTitleColor:MC_SKYBLUE_COLOR forState:UIControlStateNormal];
    touzhuBtnCopy.layer.borderWidth = 1.0f;
    touzhuBtnCopy.layer.borderColor = MC_SKYBLUE_COLOR.CGColor;
    touzhuBtnCopy.layer.cornerRadius = 2;
    [touzhuBtnCopy addTarget:self action:@selector(touzhuBtnCopyClick) forControlEvents:UIControlEventTouchUpInside];
    touzhuBtnCopy.titleLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    zhuDanDetailLabel.text = @"正在加载";
    zhuDanDetailLabel.textColor = RGB(102, 102, 102);
    zhuDanDetailLabel.font = [UIFont systemFontOfSize:MC_REALVALUE(14)];
    UIButton *contnueBtn = [[UIButton alloc] init];
    [contnueBtn setTitle:@"继续投注" forState:UIControlStateNormal];
    [self.view addSubview:contnueBtn];
    [contnueBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    contnueBtn.backgroundColor = MC_SKYBLUE_COLOR;
    contnueBtn.layer.cornerRadius = 2;
    [contnueBtn addTarget:self action:@selector(contnueBtnCopyClick) forControlEvents:UIControlEventTouchUpInside];
   
    baseScrollView.contentSize = CGSizeMake(G_SCREENWIDTH, G_SCREENHEIGHT + 60);
    [dingDanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(baseScrollView).offset(MC_REALVALUE(25));
    }];
    
    [dingDanDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dingDanLabel.mas_right);
        make.top.equalTo(dingDanLabel);
    }];
    
     [dingDanBtnCopy mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(baseScrollView.mas_right).offset(G_SCREENWIDTH - MC_REALVALUE(10));
        make.centerY.equalTo(dingDanLabel);
        make.height.equalTo(@(25));
        make.width.equalTo(@(72));
    }];
    
    [liuShuiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(dingDanLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [liuShuiDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(liuShuiLabel.mas_right);
        make.top.equalTo(liuShuiLabel);
    }];
    [liuShuiBtnCopy mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(dingDanBtnCopy);
        make.centerY.equalTo(liuShuiLabel);
        make.height.equalTo(@(25));
        make.width.equalTo(@(72));
    }];
    [zhuiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(liuShuiLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [zhuiDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(zhuiLabel.mas_right);
        make.top.equalTo(zhuiLabel);
    }];
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(zhuiLabel.mas_bottom).offset(MC_REALVALUE(25));
        make.left.equalTo(baseScrollView.mas_left).offset(MC_REALVALUE(10));
        make.width.equalTo(@(G_SCREENWIDTH - MC_REALVALUE(20)));
        make.height.equalTo(@(0.5 ));
    }];

    [lotteryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(zhuiLabel);
        make.top.equalTo(lineView1.mas_bottom).offset(MC_REALVALUE(20));
    }];
    lotteryBtn.textAlignment = NSTextAlignmentRight;
    [lotteryBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(dingDanBtnCopy);
        make.centerY.equalTo(lotteryLabel);
        make.height.equalTo(@(25));
        make.width.equalTo(@(120));
        
    }];
    [qihaoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(lotteryLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [qihaoDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(qihaoLabel.mas_right);
        make.top.equalTo(qihaoLabel);
    }];
    [kaiJiangLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(qihaoLabel);
        make.top.equalTo(qihaoLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    
    [wanfaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(kaiJiangLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [wanfaDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(wanfaLabel.mas_right);
        make.top.equalTo(wanfaLabel);
    }];
    
    [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(wanfaLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [dateDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dateLabel.mas_right);
        make.top.equalTo(dateLabel);
    }];

    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(dateLabel.mas_bottom).offset(MC_REALVALUE(25));
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.width.equalTo(@(G_SCREENWIDTH - MC_REALVALUE(20)));;
        make.height.equalTo(@(0.5));
    }];
    [zhuDanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(lineView2.mas_bottom).offset(MC_REALVALUE(25));
    }];
    [zhuDanDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(zhuDanLabel.mas_right);
        make.top.equalTo(zhuDanLabel);
    }];
    [gouMaiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(zhuDanLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [gouMaiDeailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(gouMaiLabel.mas_right);
        make.top.equalTo(gouMaiLabel);
    }];
   
    [zhongJLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(gouMaiLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [zhongJDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(zhongJLabel.mas_right);
        make.top.equalTo(zhongJLabel);
    }];
    [jiangJinLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(zhongJLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    [jiangJinDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(jiangJinLabel.mas_right);
        make.top.equalTo(jiangJinLabel);
    }];
    
    [touzhuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(baseScrollView).offset(MC_REALVALUE(10));
        make.top.equalTo(jiangJinLabel.mas_bottom).offset(MC_REALVALUE(15));
    }];
    
    
    [touzhuDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(touzhuLabel.mas_right);
        make.width.equalTo(@(G_SCREENWIDTH - 82 - 90));
        make.top.equalTo(touzhuLabel);
    }];
    [touzhuBtnCopy mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(touzhuLabel);
        make.right.equalTo(dingDanBtnCopy);
        make.height.equalTo(@(25));
        make.width.equalTo(@(72));
    }];
    
    [contnueBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.bottom.equalTo(self.view);
        make.height.equalTo(@(MC_REALVALUE(45)));
    }];
    self.wanfaLabel = wanfaLabel;
    self.dateLabel = dateLabel;
    self.lineView2 = lineView2;
    self.zhuDanLabel = zhuDanLabel;
    self.gouMaiLabel= gouMaiLabel;
    self.zhongJLabel= zhongJLabel;
    self.jiangJinLabel= jiangJinLabel;
    self.touzhuBtnCopy= touzhuBtnCopy;
    self.touzhuLabel = touzhuLabel;
    self.contnueBtn= contnueBtn;
   self.dingDanDetailLabel = dingDanDetailLabel;
   self.liuShuiDetailLabel = liuShuiDetailLabel;
   self.zhuiDetailLabel = zhuiDetailLabel;
   self.lotteryLabel = lotteryLabel;
   self.qihaoDetailLabel = qihaoDetailLabel;
   self.wanfaDetailLabel = wanfaDetailLabel;
   self.dateDetailLabel = dateDetailLabel;
   self.zhuDanDetailLabel = zhuDanDetailLabel;
   self.jiangJinDetailLabel = jiangJinDetailLabel;
   self.gouMaiDeailLabel =  gouMaiDeailLabel;
    self.zhongJDetailLabel = zhongJDetailLabel;
    self.touzhuDetailLabel = touzhuDetailLabel;
    self.dingDanBtnCopy = dingDanBtnCopy;
    
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.itemSize = CGSizeMake(MC_REALVALUE(30), MC_REALVALUE(30));
    layout.minimumLineSpacing = 5;
    layout.minimumInteritemSpacing = 5;
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(87, MC_REALVALUE(210),MC_REALVALUE(G_SCREENWIDTH - 92),MC_REALVALUE(30)) collectionViewLayout:layout];
    [collectionView registerClass:[MCGameRecordDetailCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([MCGameRecordDetailCollectionViewCell class])];
    
    collectionView.dataSource = self;
    self.collectionView = collectionView;
    collectionView.backgroundColor = [UIColor whiteColor];
    [self.baseScrollView addSubview:collectionView];
    
    
    
  NSString *str = [MCLotteryID getLotteryFullNameByID:self.dataSource.PlayCode];

 

    
    if ([str isEqualToString:@"ssc"]) {
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?"]];
        
    } else if ([str isEqualToString:@"esf"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"sd"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"pls"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"plw"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"ssl"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"kl8"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?"]];
    }else if ([str isEqualToString:@"pks"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?"]];
    }else if ([str isEqualToString:@"k3"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?"]];
        
    }else if ([str isEqualToString:@"tb"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?"]];
       
    }else if([str isEqualToString:@"klsf"]){
        self.collectionViewArray = [NSMutableArray arrayWithArray:@[@"?",@"?",@"?",@"?",@"?",@"?",@"?",@"?"]];
    }
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];

}
- (void)contnueBtnCopyClick{
    
    
    MCUserDefinedLotteryCategoriesModel *model = [MCUserDefinedLotteryCategoriesModel GetMCUserDefinedLotteryCategoriesModelWithCZID:self.data.LotteryCode];
    MCPickNumberViewController *pickVc = [[MCPickNumberViewController alloc] init];
    pickVc.lotteriesTypeModel = model;
    pickVc.palyCode=self.dataSource.PlayCode;
    pickVc.navigationItem.title = [MCLotteryID getLotteryCategoriesNameByID:self.data.LotteryCode];
    [self.navigationController pushViewController:pickVc animated:YES];

}
- (void)touzhuBtnCopyClick{
    
    UIPasteboard *pab = [UIPasteboard generalPasteboard];
    
    NSString *string = self.dingDanDetailLabel.text;
    
    [pab setString:string];
    
    if (pab == nil) {
        
        [SVProgressHUD showErrorWithStatus:@"复制失败"];
        
    }else{
        
        [SVProgressHUD showSuccessWithStatus:@"已复制"];
        
    }

}

- (void)liuShuiBtnCopyClick{
    
    UIPasteboard *pab = [UIPasteboard generalPasteboard];
    
    NSString *string = self.dingDanDetailLabel.text;
    
    [pab setString:string];
    
    if (pab == nil) {
        [SVProgressHUD showErrorWithStatus:@"复制失败"];
        
    }else
    {
        [SVProgressHUD showSuccessWithStatus:@"已复制"];
    }

}
- (void)dingDanBtnCopyClick{
    
    UIPasteboard *pab = [UIPasteboard generalPasteboard];
    
    NSString *string = self.dingDanDetailLabel.text;
    
    [pab setString:string];
    
    if (pab == nil) {
        [SVProgressHUD showErrorWithStatus:@"复制失败"];
        
    }else
    {
        [SVProgressHUD showSuccessWithStatus:@"已复制"];
    }

}
- (void)cancleBtnClick:(UIButton *)btn{
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"撤单" message:@"是否确认撤单？" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action){
    
    }];
    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
        
        MCCancleLotteryModel *model = [[MCCancleLotteryModel alloc] init];
        self.cancelModel = model;
        model->_code = self.data.LotteryCode;
        model->_orderID = self.data.Bet[0].OrderID;
        [model refreashDataAndShow];
        
        model.callBackSuccessBlock = ^(id manager) {
            self.btn.hidden = YES;
            self.lotteryBtn.text = @"已撤单";
        };
        
//        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alertController addAction:cancelAction];
    [alertController addAction:okAction];
    [self presentViewController:alertController animated:YES completion:nil];
    
}


- (void)loadDataAndShow{
    
    MCGameRecordDetailModel *model = [[MCGameRecordDetailModel alloc] init];
    self.gameRecordModel = model;
//    model->_ChaseOrderID = self.dataSource.ChaseOrderID;
    model->_OrderID = self.dataSource.OrderID;
    model->_InsertTime = self.dataSource.InsertTime;
    model->_IsHistory = self.isHistory;
    model->_LotteryCode = self.dataSource.BetTb;
    [model refreashDataAndShow];
    model.callBackFailedBlock = ^(id manager, NSString *errorCode) {
        
    };
    model.callBackSuccessBlock = ^(id manager) {
      self.data = [MCGameRecordDetailModel mj_objectWithKeyValues:manager];
        self.dingDanDetailLabel.text = self.data.Bet[0].ChaseOrderID;
        self.liuShuiDetailLabel.text = self.data.Bet[0].OrderID;
        self.lotteryLabel.text = [MCLotteryID getLotteryCategoriesNameByID:self.data.LotteryCode];
        self.qihaoDetailLabel.text = self.data.Bet[0].IssueNumber;
        
        //玩法名称
        self.wanfaDetailLabel.text = [MCLotteryID  getLotteryFullNameByPlayCode:self.data.Bet[0].PlayCode andLotteryCode:self.data.LotteryCode andBetMode:self.data.Bet[0].BetMode ];

        
        self.dateDetailLabel.text = self.data.Bet[0].InsertTime;
        int BetOrderState = self.data.Bet[0].BetOrderState;
        NSString *str = @"";
        self.btn.hidden = YES;
        if ((BetOrderState & 1) == 1) {
            str = @"【购买成功】";
            self.btn.hidden = NO;
        } else if ((BetOrderState & 32768) == 32768) {
            str = @"【已撤奖】";
           
        } else if ((BetOrderState & 64) == 64) {
            str = @"【已出票】";
            
        } else if ((BetOrderState & 16777216) == 16777216) {
            str = @"【已派奖】";
           
        } else if ((BetOrderState & 33554432) == 33554432) {
            str = @"【未中奖】";
          
        } else if ((BetOrderState & 4096) == 4096) {
            str = @"【已结算】";
            
        } else if ((BetOrderState & 512) == 512) {
            str = @"【强制结算】";
            
        } else if ((BetOrderState & 4) == 4) {
            str = @"【已撤单】";
        } else {
            str = @"【订单异常】";
          
        }
        if ((1048577 & BetOrderState) == 1048577) {
            self.btn.hidden = NO;
        } else {
            self.btn.hidden = YES;
        }
        NSString *typeSS = @"";
       int BetMode=  self.data.Bet[0].BetMode;
        if ((BetMode & 32)==32) {
            typeSS = @"元模式";
        } else if ((BetMode & 64)==64) {
            typeSS = @"角模式";
        } else if ((BetMode & 128)==128) {
            typeSS = @"分模式";
        } else if ((BetMode & 256)==256){
            typeSS = @"厘模式";
        }
        
        if ((BetMode & 2) == 2) {
            self.zhuiDetailLabel.text = @"是";
        } else if ((BetMode & 4) == 4) {
            self.zhuiDetailLabel.text = @"否";
        } else {
            self.zhuiDetailLabel.text = @"--";
        }

      
        self.lotteryBtn.text = str;
        if ([str isEqualToString:@"【已派奖】"]) {
            self.lotteryBtn.textColor = [UIColor colorWithHexString:@"ff5757"];
        } else if([str isEqualToString:@"【未中奖】"]){
            self.lotteryBtn.textColor = [UIColor colorWithHexString:@"1baa79"];
        }else{
            self.lotteryBtn.textColor = [UIColor colorWithHexString:@"3680d3"];
        }
        NSString *teStr = @"";
        if ([self.data.Bet[0].AwContent isEqualToString:@""]||self.data.Bet[0].AwContent == nil) {
            teStr = @"0注";
        }else{
            teStr = [NSString stringWithFormat:@"%@注",self.data.Bet[0].AwContent];
        }
        self.zhongJDetailLabel.text = teStr;
        NSString *str1 =  [NSString stringWithFormat:@"%@|%@|%@倍|%d注",typeSS,self.data.BetRebate,self.data.Bet[0].BetMultiple,self.data.Bet[0].BetCount];
        self.zhuDanDetailLabel.text = str1;
        self.jiangJinDetailLabel.text = self.data.Bet[0].BetMoney;
      

        self.jiangJinDetailLabel.text = [NSString stringWithFormat:@"%@元",self.data.Bet[0].AwMoney];
        
        self.gouMaiDeailLabel.text = [NSString stringWithFormat:@"%@元",self.data.Bet[0].BetMoney];
        self.collectionView.top = self.kaiJiangLabel.top;
        if ([self.data.Bet[0].DrawContent isEqualToString:@""] ||self.data.Bet[0].DrawContent == nil ) {
            
            self.collectionView.centerY = self.kaiJiangLabel.centerY;
            
        } else {
           
            
            NSArray *arr = [self.data.Bet[0].DrawContent componentsSeparatedByString:@","];
            
            [self.collectionViewArray removeAllObjects];
   
            [self.collectionView reloadData];
            
            self.collectionViewArray = [NSMutableArray arrayWithArray:arr];

            //快乐8干掉 飞盘号
            if ([self.data.LotteryCode isEqualToString: @"9"]||[self.data.LotteryCode isEqualToString: @"79"]||[self.data.LotteryCode isEqualToString: @"80"]) {
                
                [self.collectionViewArray removeLastObject];
            }
  
        }
        
        if (self.collectionViewArray.count>8) {
            
            [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.kaiJiangLabel.mas_right);
                make.top.equalTo(self.kaiJiangLabel);
                make.width.equalTo(@(MC_REALVALUE(G_SCREENWIDTH - 92)));
                make.height.equalTo(@(MC_REALVALUE(35) * ceilf(self.collectionViewArray.count/8.0)));
            }];
            [self.wanfaLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.kaiJiangLabel.mas_bottom).offset(MC_REALVALUE(35) * ceilf(self.collectionViewArray.count/8.0) + 10);
            }];
            [self.wanfaDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.wanfaLabel.mas_right);
                make.top.equalTo(self.wanfaLabel);
            }];
            
            [self.dateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.wanfaLabel.mas_bottom).offset(MC_REALVALUE(15));
            }];
            [self.dateDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.dateLabel.mas_right);
                make.top.equalTo(self.dateLabel);
            }];
            
            [self.lineView2 mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.top.equalTo(self.dateLabel.mas_bottom).offset(MC_REALVALUE(25));
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.width.equalTo(@(G_SCREENWIDTH - MC_REALVALUE(20)));;
                make.height.equalTo(@(0.5));
            }];
            [self.zhuDanLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.lineView2.mas_bottom).offset(MC_REALVALUE(25));
            }];
            [self.zhuDanDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.zhuDanLabel.mas_right);
                make.top.equalTo(self.zhuDanLabel);
            }];
            [self.gouMaiLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.zhuDanLabel.mas_bottom).offset(MC_REALVALUE(15));
            }];
            [self.gouMaiDeailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.gouMaiLabel.mas_right);
                make.top.equalTo(self.gouMaiLabel);
            }];
            
            [self.zhongJLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.gouMaiLabel.mas_bottom).offset(MC_REALVALUE(15));
            }];
            [self.zhongJDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.zhongJLabel.mas_right);
                make.top.equalTo(self.zhongJLabel);
            }];
            [self.jiangJinLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.zhongJLabel.mas_bottom).offset(MC_REALVALUE(15));
            }];
            [self.jiangJinDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.jiangJinLabel.mas_right);
                make.top.equalTo(self.jiangJinLabel);
            }];
            
            [self.touzhuLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.baseScrollView).offset(MC_REALVALUE(10));
                make.top.equalTo(self.jiangJinLabel.mas_bottom).offset(MC_REALVALUE(15));
            }];
            NSLog(@"%@",NSStringFromCGRect(self.touzhuLabel.frame));
            
            [self.touzhuDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(self.touzhuLabel.mas_right);
                make.width.equalTo(@(G_SCREENWIDTH - 82 - 90));
                make.top.equalTo(self.touzhuLabel);
            }];
            
                  NSLog(@"%@",NSStringFromCGRect(self.touzhuDetailLabel.frame));
            [self.touzhuBtnCopy mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(self.touzhuLabel);
                make.right.equalTo(self.dingDanBtnCopy);
                make.height.equalTo(@(25));
                make.width.equalTo(@(72));
            }];
            
            [self.contnueBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.right.equalTo(self.view);
                make.bottom.equalTo(self.view);
                make.height.equalTo(@(MC_REALVALUE(45)));
            }];
        }
        [self.collectionView reloadData];
        CGRect subviewRect = [self.data.Bet[0].BetContent boundingRectWithSize:CGSizeMake(G_SCREENWIDTH -82 - 90, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(14)]} context:nil];
        
        if (subviewRect.size.height > 17) {
            
            CGRect subviewRect1 = [self.data.Bet[0].BetContent boundingRectWithSize:CGSizeMake(G_SCREENWIDTH -20, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(14)]} context:nil];
            
            self.baseScrollView.contentSize = CGSizeMake(G_SCREENWIDTH, G_SCREENHEIGHT + subviewRect1.size.height + 100);
            
            [self.touzhuDetailLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(@(10));
                make.width.equalTo(@(G_SCREENWIDTH - 20));
                make.top.equalTo(self.touzhuLabel.mas_bottom).offset(10);
            }];
            
        } else {

        }
       NSString *strTemp = [self.data.Bet[0].PlayCode stringByReplacingOccurrencesOfString:self.data.LotteryCode withString:@""];
       NSString *strBetContent = [MCMathUnits tzContentToChinese:[MCLotteryID getLotteryCategoriesTypeNameByID:self.data.LotteryCode] andMethodId:strTemp andContent:self.data.Bet[0].BetContent];
        self.touzhuDetailLabel.text = strBetContent;
        
    };
}
                                   
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    MCGameRecordDetailCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([MCGameRecordDetailCollectionViewCell class]) forIndexPath:indexPath];
    cell.dataSource=self.collectionViewArray[indexPath.row];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.collectionViewArray.count;
}
@end
